
package main;

import database.DataBase;
import model.Server;
import interfaces.ServerInterface;
import java.rmi.RemoteException;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author Anders Bo Rasmussen
 */
public class Main {
      public static void main(String[] args) {
        try {
            java.rmi.registry.LocateRegistry.createRegistry(1099);
            ServerInterface server = new Server();
            Context nameContext = new InitialContext();
            nameContext.bind("rmi:server", server);
            System.out.println("færdig med rmi");
            DataBase db = DataBase.getInstance();
            System.out.println("db connection");
            db.login("root", "root");
//          try {
//              ResultSet result = db.getResult("select * from vare");
//              
//              while ( result.next() ) {
//                  System.out.println("item " + result.getString("navn"));
//              }
//              System.out.println("udskrevet");
//              
//          } catch (SQLException ex) {
//              System.out.println("sql fejl   " + ex.getLocalizedMessage());
//          }            
            
            
        } catch (RemoteException | NamingException ex) {
            System.out.println(ex.getLocalizedMessage());
            System.out.println(ex);
        }
        
    }
}
